﻿using System;
using System.Windows;
using System.Windows.Controls;

using SBPweb.RIA.Shared.Contracts.Base;
using SBPweb.RIA.Shared.Contracts.Events;
using SBPweb.RIA.Client.Contracts.Base;

namespace SBPweb.RIA.Client.Controls.Content
{

    public class AnimationHelperControl : Control
    {

        public AnimationHelperControl()
        {
            Visibility = Visibility.Collapsed;
        }

        public double DoubleValue
        {
            get
            {
                return (double)GetValue(DoubleValueProperty);
            }
            set
            {
                SetValue(DoubleValueProperty, value);
                DoubleValueChanged(value);
            }
        }

        public static readonly DependencyProperty DoubleValueProperty = DependencyProperty.Register("DoubleValue", typeof(double), typeof(AnimationHelperControl), new PropertyMetadata((sender, e) =>
        {
            if (e.OldValue != e.NewValue)
            {
                var ah = (AnimationHelperControl)sender;
                ah.DoubleValue = (double)e.NewValue;
            }
        }));

        public event EventHandler<EventArgs<double>> DoubleValueChange;

        private void DoubleValueChanged(double newValue)
        {
            if (DoubleValueChange != null)
            {
                DoubleValueChange(this, new EventArgs<double>(newValue));
            }
        }

    }

}